﻿package com.adsame.controllors
{
	import com.adsame.core.*;
	import com.adsame.interfaces.*;
	import com.adsame.utils.*;

	public class AsamBannerControllor extends AsamControllor
	{
		public function AsamBannerControllor() : void
		{
			this.__view_map = 
			<view_root>
				<!-- 广告主体部分配置 -->
				<ad_view type="rect_view" id="simple_main">
					<attrs>
						<src><![CDATA[{{SRC_URL}}]]></src>
						<width><![CDATA[{{WIDTH}}]]></width>
						<height><![CDATA[{{HEIGHT}}]]></height>
						<valign><![CDATA[{{VALIGN}}]]></valign>
						<halign><![CDATA[{{HALIGN}}]]></halign>
						<vpadding><![CDATA[{{VPADDING}}]]></vpadding>
						<hpadding><![CDATA[{{HPADDING}}]]></hpadding>
					</attrs>

					<events>
						<click><![CDATA[banner_click]]></click>
						<timeline><![CDATA[banner_timeline]]></timeline>
						<visiting><![CDATA[banner_visiting]]></visiting>
					</events>

					<children>
						<!-- 广告关闭按钮部分配置 -->
						<ad_view type="rect_view" id="simple_closebutton">
							<attrs>
								<src><![CDATA[{{SRC_URL}}]]></src>
								<width><![CDATA[{{WIDTH}}]]></width>
								<height><![CDATA[{{HEIGHT}}]]></height>
								<valign><![CDATA[{{VALIGN}}]]></valign>
								<halign><![CDATA[{{HALIGN}}]]></halign>
								<vpadding><![CDATA[{{VPADDING}}]]></vpadding>
								<hpadding><![CDATA[{{HPADDING}}]]></hpadding>
							</attrs>

							<events>
								<click><![CDATA[banner_close]]></click>
							</events>

							<children>
							</children>

						</ad_view>
					</children>
				</ad_view>
			</view_root>;

			this.__default_config = {
				banner_prefix 		: int(Math.random() * 10000),
				banner_src_url 		: "http://192.168.12.7/test9/olga/closebtn.png",
				banner_width 		: 300,
				banner_height 		: 250,
				banner_valign 		: "center",
				banner_halign 		: "center",
				banner_vpadding 	: 0,
				banner_hpadding 	: 0,
				closebtn_src_url 	: "http://192.168.12.7/test9/olga/closebtn.png",
				closebtn_width 		: 16,
				closebtn_height 	: 16,
				closebtn_valign 	: "top",
				closebtn_halign 	: "right",
				closebtn_vpadding 	: 0,
				closebtn_hpadding 	: 0
			};
		}

		/**
		 * setParams 
		 * 
		 * @param params : IAsamParams $params : IAsamParams 
		 * @access public
		 * @return void
		 */
		public override function setParams(params : IAsamParams) : void
		{
			var root_node : XML = this.__view_map[0];

			var attrs1 = root_node.children()[0].children()[0];
			attrs1.children()[0].children()[0] = this._getParamValue("banner_src_url", params);					// banner : src
			attrs1.children()[1].children()[0] = this._getParamValue("banner_width", params);					// banner : width
			attrs1.children()[2].children()[0] = this._getParamValue("banner_height", params);					// banner : height
			attrs1.children()[3].children()[0] = this._getParamValue("banner_valign", params);					// banner : valign
			attrs1.children()[4].children()[0] = this._getParamValue("banner_halign", params);					// banner : halign
			attrs1.children()[5].children()[0] = this._getParamValue("banner_vpadding", params);				// banner : vpadding
			attrs1.children()[6].children()[0] = this._getParamValue("banner_hpadding", params);				// banner : hpadding

			attrs1 = root_node.children()[0].children()[2].children()[0].children()[0];
			attrs1.children()[0].children()[0] = this._getParamValue("closebtn_src_url", params);				// closebutton : src
			attrs1.children()[1].children()[0] = this._getParamValue("closebtn_width", params);					// closebutton : width
			attrs1.children()[2].children()[0] = this._getParamValue("closebtn_height", params);				// closebutton : height
			attrs1.children()[3].children()[0] = this._getParamValue("closebtn_valign", params);				// closebutton : valign
			attrs1.children()[4].children()[0] = this._getParamValue("closebtn_halign", params);				// closebutton : halign
			attrs1.children()[5].children()[0] = this._getParamValue("closebtn_vpadding", params);				// closebutton : vpadding
			attrs1.children()[6].children()[0] = this._getParamValue("closebtn_hpadding", params);				// closebutton : hpadding
		}
		/* ==================== 成员函数定义结束 ==================== */
	}
}
